﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <link rel="stylesheet" type="text/css" href="/UIFramkwork/jquery_easyui_1_3_2/themes/default/easyui.css" />   
    <link rel="stylesheet" type="text/css" href="/UIFramkwork/jquery_easyui_1_3_2/themes/icon.css" />   
    <link href="../../../Styles/css.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="/UIFramkwork/jquery_easyui_1_3_2/jquery-1.8.0.min.js"></script>   
    <script type="text/javascript" src="/UIFramkwork/jquery_easyui_1_3_2/jquery.easyui.min.js"></script> 
    <script type="text/javascript" src="/js/JQPrototype.js" ></script>
</head>
<body>
 <div  class="PageTitle" >
       系统管理 >> 数据字典 >> 键值列表
 </div>
 <div title="搜索区">
   <table class="searchtable">
 
       
                  <tr>
				  
                    <th>分类编码：</th>
					<td> 
					
                    <input class="easyui-combobox" 
                    id="CategoryCode_ComboBox"
                    name="CategoryCode_ComboBox"
                    data-options="
                    url:'/DataAccessCommon/GetData.ashx?m=GetJsonDataByCategoryCode&DataTable=DataDictionaryCategory&KeyField=CategoryName&ValueField=CategoryCode',
                    valueField:'id',
                    textField:'text',
                    panelHeight:'auto'
                    ">
					</td>
				  
                    <th>键名：</th>
					<td> 
					
					<input id="DataKey_Ipt"  />  
					
					</td>
				
                  </tr>
			
                  <tr>
				  
                    <th>键值：</th>
					<td> 
					
					<input id="DataValue_Ipt"  />  
					
					</td>
				  
                    <th>排序：</th>
					<td> 
					
					<input  id="OrderNumber_NumberBox"  class="easyui-numberbox"   /> 
                    
					</td>
				
                  </tr>
			
 
	 <tr>
	   <th> </th>
	   <td style=" text-align:left;" colspan="4" >
          <a id="btn" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'"  onclick="Search();" >查询</a>  
       </td>
	 </tr>
     
   </table>
 </div>
 <table id="dg"></table>  
 <div id="DivPager" style="background:#efefef;border:1px solid #ccc; margin-top:2px;"></div> 
  
 
</body>
</html>



<script type="text/javascript">
    VerGlobal = Date();
    BaseUrl = "/DataAccess/DataDictionaryTBL/GetData.ashx?m=GetDataList";
    CurrentRequestDataUrl = "";
    CurrentCondition = "";
</script>
<script type="text/javascript">
    /*************************  控件初始化 Start  ***************************/

    /*
    $('#PDepartmentID_Ipt').combotree({
    url: '/DataAccess/DataDictionaryTBL/GetData.ashx?m=GetAllJsonTreeData',
    width: 200
    });
    */


    /*************************  控件初始化 End  ***************************/
</script>

 
<script type="text/javascript">
    $('#DivPager').pagination({
        onSelectPage: function (pageNumber, pageSize) {
            $(this).pagination('loading');
            loadPageData(pageNumber, pageSize);
            $(this).pagination('loaded');
        }
    });
    $('#DivPager').pagination({
        onRefresh: function (pageNumber, pageSize) {
            VerGlobal = Date();
            $(this).pagination('loading');
            CurrentRequestDataUrl += "&Ver=" + Date();
            loadData(CurrentRequestDataUrl);
            $(this).pagination('loaded');
        }
    });



    // 加载数据
    function loadData(targetUrl) {
        $.ajax({
            type: "Get",
            url: targetUrl + "&VerGlobal=" + VerGlobal,
            dataType: "json",
            success: function (JsonResult) {
                if (JsonResult.IsSuccess) {
                    // 成功
                    ////////////////////// 绑定数据Start  ////////////////////
                    var rows = JsonResult.rows;
                    if (rows) {

                        $('#dg').datagrid({
                            data: rows,
                            columns: [[

							{ field: 'ID', title: '序号' },

							{ field: 'CategoryCode', title: '分类编码' },

							{ field: 'DataKey', title: '键名' },

							{ field: 'DataValue', title: '键值' },

							{ field: 'OrderNumber', title: '排序' },

                            { field: " ", title: '操作', formatter: formatEdit }
                                     ]]
                        });

                    } else {
                        alert("对不起，没数据！");

                        $('#dg').datagrid({
                            data: []

                        });
                    }
                    //// -------------------------------------- //////

                    if (JsonResult.total) {
                        $('#DivPager').pagination({
                            total: JsonResult.total
                        });
                    }

                    //////////////////// 绑定数据End  ///////////////

                } else {
                    // 失败
                    alert("失败：" + JsonResult.ReturnMessage);
                    $('#dg').datagrid({
                        data: []
                    });
                }

            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert(XMLHttpRequest.responseText);
            }

        });

    }


    function formatEdit(val, row, index) {
        return "<a href='DataDictionaryOperate.htm?id=" + row.ID + "&showbackbtn=true'>编辑</a> <a href='javascript:DeleteByID(" + row.ID + ");' onclick='return confirm(\"真的要删除？\");'>删除</a>";

    }

    function formatIsEnabled(val, row) {
        if (val) {
            return "<font color='green'><b>是</b></font>";
        } else {
            return "<font color='gray'>否</font>";
        }
    }






    // 加载首页数据
    function loadFirstPage() {
        var tempurl = BaseUrl + "&selecttypename=firstpage&pagesize=" + $('#DivPager').pagination('options').pageSize + GetCondition(true);
        CurrentRequestDataUrl = tempurl;
        loadData(CurrentRequestDataUrl);

        $('#DivPager').pagination({
            pageNumber: 1
        });




    }

    // 加载指定页数据
    function loadPageData(pageNumber, pageSize) {
        var tempurl = BaseUrl + "&selecttypename=gotopage&page=" + pageNumber + "&pagesize=" + pageSize + GetCondition(false);
        CurrentRequestDataUrl = tempurl;
        loadData(CurrentRequestDataUrl);
    }
    function GetCondition(refresh) {
        if (refresh) {
            CurrentCondition = "";




            try {
                if ($('#CategoryCode_ComboBox').combobox('getValue') != "") {
                    CurrentCondition += "&s_CategoryCode=" + escape($('#CategoryCode_ComboBox').combobox('getValue'));
                }
            } catch (err) {
                txt = "此页面存在一个错误。\n\n"
                txt += "错误描述: " + err.description + "\n\n"
            }





            if ($('#DataKey_Ipt').val() != "") {
                CurrentCondition += "&s_DataKey=" + escape($('#DataKey_Ipt').val());
            }





            if ($('#DataValue_Ipt').val() != "") {
                CurrentCondition += "&s_DataValue=" + escape($('#DataValue_Ipt').val());
            }





            if ($('#OrderNumber_NumberBox').val() != "") {
                CurrentCondition += "&s_OrderNumber=" + escape($('#OrderNumber_NumberBox').val());
            }




        }
        return CurrentCondition;
    }


    function OpenEditWin(id) {

    }
    function DeleteByID(id) {
        var dataStr = "m=DeleteByID&id=" + id + "&ver=" + Date();
        $.ajax({
            type: "Get",
            url: "/DataAccess/DataDictionaryTBL/OperateData.ashx",
            data: dataStr,
            dataType: "json",
            success: function (JsonResult) {
                if (JsonResult.IsSuccess) {
                    // 成功

                    alert(JsonResult.ReturnMessage);
                    VerGlobal = Date();
                    loadData(CurrentRequestDataUrl);

                } else {
                    // 失败
                    alert("失败：" + JsonResult.ReturnMessage);
                }

            }
        });
    }

    function Search() {
        VerGlobal = Date();
        loadFirstPage();
    }
    

</script>
<script type="text/javascript">
    loadFirstPage();
</script>


